// 13math.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>

#define MAX_NUM  1000
unsigned char sieve[MAX_NUM+1];

void findPrime()
{
	long i, j;

	for (i=2; i <= MAX_NUM; i++)
	{
        sieve[i] = 1;
	}

    for (i=2; i <= MAX_NUM; i++)
    {
		if (sieve[i] == 1)
		{
			for (j=i*i; j <= MAX_NUM; j += i)
			{
				sieve[j] = 0;
			}
       }
   }
}

void printPrime()
{
	long i, k=0;

    for (i=2; i <= MAX_NUM; i++)
    {
		if (sieve[i] == 1)
		{
			k++;
			printf("%ld, ",  i);  
			if (k % 15 == 0)   
			{
				printf("\n");   
				k = 0;
			}
       }
   }

   printf("\n");
}

void main()
{
	findPrime();
	printPrime();
}
